package com.fzy.designpattern.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * 代理类生成器
 */
public class ProxyHandler implements InvocationHandler {

    RealStar realStar;

    public ProxyHandler(RealStar realStar) {
        this.realStar = realStar;
    }

    /**
     * 任何调用真实角色的方法都会到这里来
     */
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        System.out.println("方法操作之前");

        method.invoke(realStar, args);

        System.out.println("方法操作之后");

        return null;
    }


}

